package com.vma.interfaceShoes.controller;

import com.jfinal.core.Controller;
import com.jfinal.kit.HttpKit;
import com.jfinal.log.Log;
import com.jfinal.log.Log4jLog;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.vma.interfaceShoes.util.ReturnsUtil;
import com.vma.offer.service.MarketService;
import com.vma.offer.service.OfferService;
import com.vma.shoes.bizModel.model.Market;
import net.sf.json.JSONObject;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * Created by chenzui on 2017/4/18.
 */
public class MarketController extends Controller{
    public void qryMarketList(){
        try {
            Page<Market> list = MarketService.qryMarketList(getParaToInt("cPage"),getParaToInt("pSize"),getPara("theme"),"1",null,null,null);
            renderJson(ReturnsUtil.returnSuccess(list));

        }catch (Exception e){
            e.printStackTrace();
            renderJson(ReturnsUtil.returnException(e.getMessage(),e));
        }
    }


    /**
     * 查询专场下商品信息，包含是否收藏
     */
    public void qryOffersByMarket(){
        try {
            Integer cPage = getParaToInt("cPage");
            Integer pSize = getParaToInt("pSize");
            Integer marketId = getParaToInt("marketId");
            Integer userId = getParaToInt("userId");
            String type = getPara("type");
            String brandId = getPara("brandId") ;
            String action = getPara("action") ;
            String start = getPara("start");
            String end = getPara("end");
            Page<Record> offers = OfferService.qryOfferListByMarket(userId,cPage,pSize,marketId,type,brandId,action,start,end);
            renderJson(ReturnsUtil.returnSuccess(offers));
        }catch (Exception e){
            e.printStackTrace();
            renderJson(ReturnsUtil.returnException(e.getMessage(),e));
        }

    }
}
